package com.hsgene.order.constants;

/**
 * 支付状态枚举
 *
 * @author wangbing
 * @version 1.0, 2018/8/8
 */
public enum PaymentStatus {

    /**
     * 支付状态枚举
     */
    INIT(0, "未支付"),

    PAYING(1, "支付中"),

    PAID(2, "已支付"),

    UNDEFINED(-1, "未定义的支付方式");

    /**
     * 编码
     */
    private final int code;

    /**
     * 描述
     */
    private final String desc;

    public static PaymentStatus getEnum(int code) {
        for (PaymentStatus status : values()) {
            if (status.code == code) {
                return status;
            }
        }

        return UNDEFINED;
    }

    PaymentStatus(int code, String desc) {
        this.code = code;
        this.desc = desc;
    }

    public int getCode() {
        return code;
    }

    public String getDesc() {
        return desc;
    }

}
